using UnityEngine;
using System.Collections;

public class bulletScript : MonoBehaviour {
	public float life = 0.0f;
	public Vector3 dir = new Vector3(0,0,0);
	public Vector3 lastUpdate = new Vector3(0,0,0);
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		life += Time.deltaTime;
		if(life >= 10.0f){
			GameObject.Destroy(transform.gameObject);
		}
		transform.Translate(dir*50*Time.deltaTime);
	}
	void OnTriggerEnter(Collider other){
		PlayerScript p = other.GetComponent<PlayerScript>();
		if(p != null){
		GameObject.Destroy(transform.gameObject);
		}
	}
	public void setDest(Vector3 dest){
		dir = dest;
	}
	[RPC]
	void DestroyBullet(){
		print("hit");
		GameObject.Destroy(transform.gameObject);
	}
}
